# 暴力解法超时
def maxProfit(prices):
    max_profit = 0
    for i in range(len(prices)):
        for j in range(i + 1, len(prices)):
            max_profit = max(max_profit, prices[j] - prices[i])
    return max_profit


print(maxProfit([5, 1, 2, 3, 4, 10]))
print(maxProfit([6, 5, 3, 1]))
